Write me -

Cover the lung data example currently in funnel-test.R

See Vignette writing guide here

The code can be included inline bracketed with three back-ticks. See example below which imports the relevant bit of funnel-test.R

Vignettes are long form documentation commonly included in packages. Because they are part of the distribution of the package, they need to be as compact as possible. The html_vignette output type provides a custom style sheet (and tweaks some options) to ensure that the resulting html is as small as possible. The html_vignette format:

Vignette Info

Note the various macros within the vignette section of the metadata block above. These are required in order to instruct R how to build the vignette. Note that you should change the title field and the \VignetteIndexEntry to match the title of your vignette.

Styles

The html_vignette template includes a basic CSS theme. To override this theme you can specify your own CSS in the document metadata as follows:

output:
  rmarkdown::html_vignette:
    css: mystyles.css

Figures

The figure sizes have been customised so that you can easily put two images side-by-side.

plot(1:10)
plot(10:1)

You can enable figure captions by fig_caption: yes in YAML:

output:
  rmarkdown::html_vignette:
    fig_caption: yes

Then you can use the chunk option fig.cap = "Your figure caption." in knitr.

Example from funnel-test.R

####################################################
# March 2016.  Test new funnel program
#
# This code may not work as I don't have access to lung.csv (Mike)
#
####################################################
# Lung data
devtools::install_github('gmp26/funnel')
library(funnel)

###
# NB from Mike. It's probably better to put the lung.csv file in the data
# directory in this package rather than use a private dropbox.
###

#
# Using CABG data since I can't access lung-data
#
load("../data/cabg.rda") # if necessary to access cabg data
x <- cabg # cabg was created by reading CABG-hospitals-03.csv into
# cabg variable and then saving it with `devtools::use_data(cabg)`

# x<-read.csv(file="~//Dropbox//DB-funnels-HSMR//funnels//lung.csv",header=T,sep=",")

N<- x$Cases
R<- N-x$deaths
xlabel<-"Number of operations per hospital"
scale<-0.8
xrange<-c(0,max(N))
xrange=c(0,600)
# ylabel<-"Mortality rate (%)"
#yrange<-c(0,max( R/N ))
ylabel<-"Survival rate (%)"
yrange<-c(0.94, 1)
#yrange=c(0,1)
names= as.character(x$X)
title<-"LCCOP data"
tails=c(0.001, 0.025)

funnel4(obs.prop=R/N,  denom=N, pred.prop=P/N, names=names,
        plot="slice", rank="precision", riskadj=F, RASRplot=F,
        plot.target=F, title=title,xrange=xrange,
        yrange=yrange, tails=tails,xlab=xlabel,ylab=ylabel,ypercent=T,
        bandcols=c("white","lightcyan","cyan")
)

# Above code fails with:
# Error in par(mar = c(3.5, trunc(max(nchar(labs[, 1]))/2) + 3, 1, 2)) :
#  invalid value specified for graphical parameter "mar"
# In addition: Warning message:
# In max(nchar(labs[, 1])) : no non-missing arguments to max; returning -Inf

# > c(3.5, trunc(max(nchar(labs[, 1]))/2) + 3, 1, 2)
# [1] 3.5 7.0 1.0 2.0
# I don't know why this value is invalid.

More Examples

You can write math expressions, e.g. $Y = X\beta + \epsilon$, footnotes^[A footnote here.], and tables, e.g. using knitr::kable().

knitr::kable(head(mtcars, 10))

Also a quote using >:

"He who gives up [code] safety for [code] speed deserves neither." (via)



gmp26/rcljsdemo documentation built on May 17, 2019, 7:28 a.m.